<script setup lang="ts">
import { useRouter } from 'vue-router'
import { logout } from '@/api/auth'
import { useUserStore } from '@/stores/user'
import { useTokenStore } from '@/stores/token'

defineOptions({
  name: '403'
})

const $router = useRouter()
const userStore = useUserStore()
const tokenStore = useTokenStore()
async function logoutUser() {
  userStore.CLEAR_USER()
  await logout()
  tokenStore.clearToken()
  $router.push('/login')
}
async function goHome() {
  await $router.push('/')
}
</script>

<template>
  <div>抱歉，你无权访问该页面</div>
  <el-button type="primary" @click="goHome">返回首页</el-button>
  <el-button type="primary" @click="logoutUser">重新登录</el-button>
</template>
